package com.yuyuan.blog.controller;



import com.yuyuan.blog.domain.dto.BlogDailyDTO;
import com.yuyuan.blog.service.IDailyBlogService;
import com.yuyuan.common.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/blogService/dailyBlog")
public class DailyBlogController {
    @Autowired
    private IDailyBlogService dailyBlogService;

    //发布日常贴
    @PostMapping("/publish/{blogType}")
    public Result publishDaily(@RequestBody BlogDailyDTO blogDailyDTO, @PathVariable Short blogType) throws InterruptedException {
        return dailyBlogService.publishDaily(blogDailyDTO,blogType);
    }

    //更新日常贴
    @PostMapping("/update/{blogId}")
    public Result updateDaily(@RequestBody BlogDailyDTO blogDailyDTO, @PathVariable Long blogId) throws InterruptedException {
        return dailyBlogService.updateDaily(blogDailyDTO,blogId);
    }

    //获取日常贴
    @GetMapping("/{blogId}")
    public Result getSingleDaily(@PathVariable Long blogId){
        return dailyBlogService.getSingleDaily(blogId);
    }

    //分页查询日常贴
    @GetMapping("/page/{startId}")
    public Result getDailies(@PathVariable Long startId){
        return dailyBlogService.getDailies(startId);
    }

    //搜索日常帖子
    @GetMapping("/SearchDailies/{searchKeyWord}/{type}")
    public Result getSearchDailies(@PathVariable String searchKeyWord, @PathVariable Short type) throws IOException {
        return dailyBlogService.getSearchDailies(searchKeyWord, type);
    }
}
